Capture server.Serve() error in OAuth authorization flow#67
Merged
Conversation
server.Serve() ran in a goroutine with its error discarded. If Serve failed, the select would block until the 5-minute timeout instead of reporting the actual error. Capture the error via a buffered channel and add it as a case in the select for immediate feedback.
Replace the output package with cmd/pretty. The new pretty.JSON() function returns a prettified string instead of printing directly, letting callers handle their own output. Move prettifying out of ims/decode.go — DecodeToken now returns raw JSON strings, and cmd/decode.go applies pretty.JSON before printing. Remove unused DecodedToken.Signature field.
andresbott
approved these changes
Feb 27, 2026
Refactor pretty-print JSON into cmd/pretty package
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Capture
Serve()error.server.Serve(listener)ran in a goroutine with its error discarded. IfServefailed, theselectwould block until the 5-minute timeout with a generic "user timed out" error instead of reporting the actual cause. Now captured via a buffered channel and added as aselectcase for immediate feedback.Buffered channel by design. In the normal flow,
Servereturnshttp.ErrServerClosedafterShutdown(), when nobody is reading from the channel. A buffered channel (capacity 1) ensures the goroutine can always write and exit without leaking.Add documentation.
docs/oauth-serve-error.mdexplains the pattern, practical likelihood, and why the channel must be buffered.